﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;

namespace WorkWithFile
{
    class Program
    {
        static void Main(string[] args)
        {
            string newDir = @"G:\Леся\Репозиторий\Inteducation2\LesyaSmagliy\WorkWithFile\New";
            Directory.CreateDirectory(newDir);

            //string[] files = Directory.GetFiles(@"G:\Леся\Репозиторий\Inteducation2\LesyaSmagliy\WorkWithFile\Resources", "*.txt", SearchOption.TopDirectoryOnly);

            //if (Directory.Exists(newDir))
            //{
            //    foreach (var file in files)
            //    {
            //        string file2 = file.Replace("Resources", "New");
            //        File.Copy(file, file2);
            //    }
            //}

            //bool isDirectoryExist = Directory.Exists(@"G:\Леся\Репозиторий\Inteducation2\LesyaSmagliy\WorkWithFile\Resources");
            //if (isDirectoryExist)
            //{
            //    Directory.Delete(@"G:\Леся\Репозиторий\Inteducation2\LesyaSmagliy\WorkWithFile\Resources", true);
            //}

            //string text = "Paste";
            //string[] files2 = Directory.GetFiles(newDir, "*txt", SearchOption.TopDirectoryOnly);
            //foreach (var file in files2)
            //{
            //    File.WriteAllText(file, text);
            //}

            //string filePath = @"G:\Леся\Репозиторий\Inteducation2\LesyaSmagliy\WorkWithFile\Resources\Лист Microsoft Excel.xlsx";

            //Console.WriteLine("Расширение: {0}", Path.GetExtension(filePath));
            //Console.WriteLine("Расширение: {0}", Path.GetFileName(filePath));
            //Console.WriteLine("Имя файла без расширения: {0}", Path.GetFileNameWithoutExtension(filePath));
            //Console.WriteLine("Путь к каталогу: {0}", Path.GetDirectoryName(filePath));

            string htDirectory = @"G:\Леся\Репозиторий\Inteducation2\LesyaSmagliy\WorkWithFile\Resources\HT.txt";
            string htTxt = File.ReadAllText(htDirectory);
            Console.WriteLine(htTxt);

            string [] htArr = htTxt.Split(' ');
            Console.WriteLine("Кол-во слов в файле: {0}", htArr.Length);
            string word;
            int wordL = 0;
            int maxLenght = 0;
           
            //List<int> indexOfMaxL = new List <int>;
            List<string> w = new List<string>();
            for (int i = 0; i < htArr.Length; i++)
            {
                word = htArr[i];
                wordL = htArr[i].Length;
                if (wordL>maxLenght)
                {
                    maxLenght = wordL;
                    w.Clear();
                    w.Add(word);
                }

            }
            foreach (var item in w)
            {
                Console.WriteLine("Самое длинное слово: {0}", item);
            }
            





        }
    }
}
